﻿@model Mrc.Entity.AdminSession
@{
    Layout = null;
    var myMessageSub = ViewContext.HttpContext.Request.Query["sub"].ToString();
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Mrc后台管理系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/xadmin/css/font.css">
    <link rel="stylesheet" href="/xadmin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/xadmin/js/xadmin.js"></script>
    <script src="~/lib/stomp/stomp.js"></script>
    <style>

        .systemmsg {
            color: #bb1919;
        }
    </style>
</head>
<body>
    <!-- 顶部开始 -->
    <div class="container">
        <div class="logo"><a href="./index.html">Mrc V1.0</a></div>
        <div class="left_open">
            <i title="展开左侧栏" class="iconfont">&#xe699;</i>
        </div>
        @*<ul class="layui-nav left fast-add" lay-filter="">
            <li class="layui-nav-item">
                <a href="javascript:;">+新增</a>
                <dl class="layui-nav-child">
                
                    <dd><a onclick="x_admin_show('资讯','http://www.baidu.com')"><i class="iconfont">&#xe6a2;</i>资讯</a></dd>
                    <dd><a onclick="x_admin_show('图片','http://www.baidu.com')"><i class="iconfont">&#xe6a8;</i>图片</a></dd>
                    <dd><a onclick="x_admin_show('用户','http://www.baidu.com')"><i class="iconfont">&#xe6b8;</i>用户</a></dd>
                </dl>
            </li>
        </ul>*@
        <ul class="layui-nav right" lay-filter="">
            <li class="layui-nav-item">
                <a href="javascript:;">admin</a>
                <dl class="layui-nav-child">
                    <!-- 二级菜单 -->
                    @*<dd><a onclick="x_admin_show('个人信息','http://www.baidu.com')">个人信息</a></dd>
                    <dd><a onclick="x_admin_show('切换帐号','http://www.baidu.com')">切换帐号</a></dd>*@
                    <dd><a href="/admin/home/LoginOut">退出</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item to-index"><a href="/">前台首页</a></li>
        </ul>
    </div>
    <!-- 顶部结束 -->
    <!-- 中部开始 -->
    <!-- 左侧菜单开始 -->
    <div class="left-nav">
        <div id="side-nav">
            <ul id="nav">


            </ul>
        </div>
    </div>
    <!-- <div class="x-slide_left"></div> -->
    <!-- 左侧菜单结束 -->
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
            <ul class="layui-tab-title">
                <li class="home"><i class="layui-icon">&#xe68e;</i>我的桌面</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <iframe src='/admin/home/Welcome' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
                </div>
            </div>
        </div>
    </div>
    <div class="page-content-bg"></div>
    <script>
          //声明个Stompjs客户端
          var client = Stomp.client("ws://192.168.1.228:15674/ws");
          //监听连接事件
          var on_connect = function (x) {
              id = client.subscribe("/topic/@Model.AccountName.ToLower()", function (d) {
                  layer.msg(d.body, { offset: 'rt', skin:'systemmsg'});
              });
          };
          var on_error = function () {
              console.log('error');
          };
          //连接MQ
        client.connect('guest', 'guest', on_connect, on_error, '/');
    </script>
    <script>
        layui.use(['form', 'element'], function () {
               var layer = layui.layer;
              var element = layui.element;
            $.get('/admin/home/LeftNav', function (repo) {
                var data = repo.data;
                for (var i = 0; i < data.length; i++)
                {
                    getNode(data[i]);
                }
                //触发事件
                var tab = {
                    tabAdd: function (title, url, id) {
                        //新增一个Tab项
                        element.tabAdd('xbs_tab', {
                            title: title
                            , content: '<iframe tab-id="' + id + '" frameborder="0" src="' + url + '" scrolling="yes" class="x-iframe"></iframe>'
                            , id: id
                        });
                    }
                    , tabDelete: function (othis) {
                        //删除指定Tab项
                        element.tabDelete('xbs_tab', '44'); //删除：“商品管理”
                        othis.addClass('layui-btn-disabled');
                    }
                    , tabChange: function (id) {
                        //切换到指定Tab项
                        element.tabChange('xbs_tab', id); //切换到：用户管理
                    }
                };

                $('.container .left_open i').click(function (event) {
                    if ($('.left-nav').css('left') === '0px') {
                        $('.left-nav').animate({ left: '-221px' }, 50);
                        $('.page-content').animate({ left: '0px' }, 50);
                        $('.page-content-bg').hide();
                    } else {
                        $('.left-nav').animate({ left: '0px' }, 50);
                        $('.page-content').animate({ left: '221px' }, 50);
                        if ($(window).width() < 768) {
                            $('.page-content-bg').show();
                        }
                    }

                });

                $('.page-content-bg').click(function (event) {
                    $('.left-nav').animate({ left: '-221px' }, 50);
                    $('.page-content').animate({ left: '0px' }, 50);
                    $(this).hide();
                });

                $('.layui-tab-close').click(function (event) {
                    $('.layui-tab-title li').eq(0).find('i').remove();
                });

                $("tbody.x-cate tr[fid!='0']").hide();
                //左侧菜单效果
                $('.left-nav #nav li').click(function (event) {
                    if ($(this).children('.sub-menu').length)
                    {
                        if ($(this).hasClass('open'))
                        {
                            $(this).removeClass('open');
                            $(this).find('.nav_right').html('&#xe697;');
                            $(this).children('.sub-menu').stop().slideUp();
                            $(this).siblings().children('.sub-menu').slideUp();
                        }
                        else
                        {
                            $(this).addClass('open');
                            $(this).children('a').find('.nav_right').html('&#xe6a6;');
                            $(this).children('.sub-menu').stop().slideDown();
                            $(this).siblings().children('.sub-menu').stop().slideUp();
                            $(this).siblings().find('.nav_right').html('&#xe697;');
                            $(this).siblings().removeClass('open');
                        }
                    }
                    else
                    {

                        var url = $(this).children('a').attr('_href');
                        var title = $(this).find('cite').html();
                        var index = $('.left-nav #nav li').index($(this));
                        for (var i = 0; i < $('.x-iframe').length; i++)
                        {
                            if ($('.x-iframe').eq(i).attr('tab-id') == index + 1) {
                                tab.tabChange(index + 1);
                                event.stopPropagation();
                                return;
                            }
                        }
                        tab.tabAdd(title, url, index + 1);
                        tab.tabChange(index + 1);
                    }
                    event.stopPropagation();
                });

            });
            function getNode(nodeData) {
                var text = "";
                text += "                <li>";
                text += "                    <a href=\"javascript:;\">";
                text += "                        <i class=\"iconfont\">&#xe723;</i>";
                text += "                        <cite>" + nodeData.title + "</cite>";
                text += "                        <i class=\"iconfont nav_right\">&#xe697;</i>";
                text += "                    </a>";
                text += "                    <ul class=\"sub-menu\">";
                if (nodeData.children.length > 0)
                {
                    var childs = nodeData.children;
                    for (var i = 0; i < childs.length; i++)
                    {
                        text += "                        <li>";
                        text += "                            <a _href=\"" + childs[i].basicData.url + "\">";
                        text += "                                <i class=\"iconfont\">&#xe6a7;</i>";
                        text += "                                <cite>" + childs[i].title + "</cite>";
                        text += "                            </a>";
                        text += "                        </li>";
                    }
                }
                text += "                    </ul>";
                text += "                </li>";
                $("#nav").append(text);
            }

        });

    </script>
</body>
</html>